#ifndef MYSQL_CONN_FIXTURE_HPP_
#define MYSQL_CONN_FIXTURE_HPP_

#include "mysql_conn_fixture_base.hpp"
#include "odbc/connection_concept.hpp"
#include "odbc/basic_statement.hpp"
#include "odbc/prepared_stat_exec_policy.hpp"
#include <boost/test/auto_unit_test.hpp>

template< class Connection>
struct mysql_conn_fixture: public mysql_conn_fixture_base
{
	BOOST_CONCEPT_ASSERT( (odbc::connection_concept< Connection>));

	mysql_conn_fixture()
		: connection_( connection_string_, 10) { }

	Connection connection_;
};


template< class Connection>
struct mysql_conn_dataset_fixture: public mysql_conn_fixture< Connection>
{
	mysql_conn_dataset_fixture( const std::string& table_name = "dbtype_test_data")
		: table_name_( table_name)
	{
		this->clean_table();
	}

	~mysql_conn_dataset_fixture()
	{
		this->clean_table();
	}

	void clean_table()
	{
		odbc::basic_statement< odbc::prepared_stat_exec_policy> stat(
				this->connection_, "delete from " + table_name_);
		ODBCTEST_CHECK_NOTHROW( stat.execute());
	}

private:
	std::string table_name_;
};

#endif /* MYSQL_CONN_FIXTURE_HPP_ */
